#include "Tank.h"

using namespace DKGL;

Tank::Tank() : 
	Movable("Tank")
{
	construct();
}


Tank::~Tank()
{}


void Tank::construct()
{
	using namespace primitive;

	MaterialPtr darkGreen = MaterialPtr(new Material("DarkGreen"));
	MaterialPtr lightGreen = MaterialPtr(new Material("DarkGreen"));

	darkGreen->setColor(0.0f, 0.2f, 0.0f);
	lightGreen->setColor(0.5f, 1.0f, 0.5f);

	// Base
	Box* tankBase = new Box("TankBase", 6.0f, 4.0f, 6.0f);
	tankBase->setMaterial(0, darkGreen);

	MovablePtr tankBaseNode = MovablePtr(new Movable("TankBaseNode"));
	tankBaseNode->translate(0.0f, 2.0f, 0.0f, LOCAL);
	tankBaseNode->addDrawable(tankBase);

	// Turret
	Box* tankTurret = new Box("TankTurret", 3.0f, 2.0f, 3.0f);
	tankTurret->setMaterial(0, lightGreen);

	MovablePtr tankTurretNode = MovablePtr(new Movable("TankTurretNode"));
	tankTurretNode->translate(0.0f, 3.0f, 0.0f, LOCAL);
	tankTurretNode->addDrawable(tankTurret);

	// Gun
	Box* tankGun = new Box("TankGun", 1.0f, 1.0f, 6.0f);
	tankGun->setMaterial(0, darkGreen);

	MovablePtr tankGunNode = MovablePtr(new Movable("TankGunNode"));
	tankGunNode->translate(0.0f, 0.0f, -4.5f, LOCAL);
	tankGunNode->addDrawable(tankGun);

	// Composite
	addChild(tankBaseNode);
	tankBaseNode->addChild(tankTurretNode);
	tankTurretNode->addChild(tankGunNode);
}